package com.teamone.etl.systemsettings.controller;


import com.baomidou.mybatisplus.extension.api.ApiController;
import com.baomidou.mybatisplus.extension.api.R;
import com.teamone.etl.systemsettings.entity.Department;
import com.teamone.etl.systemsettings.service.DepartmentService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 部门
 *
 * (Department)表控制层
 *
 * @author makejava
 * @since 2021-01-20 14:31:58
 */
@RestController
@RequestMapping("department")
public class DepartmentController extends ApiController {
    /**
     * 服务对象
     */
    @Resource
    private DepartmentService departmentService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public R selectOne(Integer id) {
        return success(departmentService.selectOne(id));
    }

    /**
     * 添加部门
     *
     * @return  部门信息
     */
    @PostMapping("/createDepartment")
    public R createDepartment(@RequestBody Department department) {

        Boolean department1 = departmentService.createDepartment(department);

        return success(department1);
    }

    /**
     * 查询部门下所有岗位
     *
     * @param id 部门岗位
     * @return 部门岗位
     */
    @GetMapping("/selectCountPost")
    public R selectCountPost(Integer id) {

        return success(departmentService.selectCountPost(id));
    }
}